<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOperationLogRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('operation_log_record', function (Blueprint $table) {
            $table->id();

            $table->string("route_file")->comment("路由文件名称")->default("");
            $table->string("route")->comment("日志所属路由地址")->default("");
            $table->string("request_method")->comment("请求方法");
            $table->json("request_params")->comment("请求参数");


            $table->string("module", 60)->comment("所属模块")->default("");
            $table->string("name", 60)->comment("日志记录名称")->default("");
            $table->string("desc", 60)->comment("日志记录描述")->default("");
            $table->string("business_mark", 120)->comment("业务标识")->default("");
            $table->json("log_content")->comment("日志内容");

            $table->unsignedBigInteger('operate_userid')->default(0)->comment('操作人ID');
            $table->string('operate_username', 120)->default("")->comment('操作人名称');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->index(['module', 'name', 'createdAt'], 'idx_moduleName');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '通用 - 操作日志表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('operation_log_record');
    }
}
